#ifndef MY_RENDER_ROUND
#define MY_RENDER_ROUND

#include "./object.hpp"
#include "../config.hpp"
#include "../dot.hpp"
#include "../vector4.hpp"
#include "./triangle.hpp"


namespace object{

    // 特殊的二维图形，一个圆
    class Round: public Object{
        public:
        float radius;
        const int vertexCount=RoundVertexCount;

        // 生成一个圆,圆的原始方向为垂直于z轴
        Round(Dot position,float radius ,Vector4 rotation):Object(position,rotation){
            this->radius=radius;
            for(int i=0;i<vertexCount;i++){
                float angle=i*2*M_PI/vertexCount;
                float x=radius*cos(angle);
                float y=radius*sin(angle);
                // 配合上position得到新的圆
                vertices.push_back(Dot(x+position.x,y+position.y,position.z));
            }
            // 插入全部点之后进行旋转
            rotate(rotation.x,rotation.y,rotation.z);
        }
    };
    // 纯色的一个圆，但是问题是，渲染器的底层逻辑是渲染所有的三角形，所以这里必须新建无数个对应多个三角形
    class ColorRound:public Round,public ColorTriangleComponent{
        public:
        float red;
        float green;
        float blue;
        ColorRound(Dot position,float radius,Vector4 rotation,float red,float green,float blue):Round(position,radius,rotation),ColorTriangleComponent(),red(red),green(green),blue(blue){
            // 首先新增一个点，即圆心
            vertices.push_back(position);
            // 生成三角形
            for(int i=0;i<vertexCount;i++){
                int index1=i;
                int index2=(i+1)%vertexCount;
                int index3=vertexCount;
                colorTriangles.push_back(ColorTriangle(index1,index2,index3,red,green,blue));
            }
            rotate(rotation.x,rotation.y,rotation.z);
        }
        // 简化版的构造函数
        ColorRound(Dot position,float radius):Round(position,radius,Vector4(0,0,0)),ColorTriangleComponent(),red(0),green(0),blue(1){
            vertices.push_back(position);
            // 生成三角形
            for(int i=0;i<vertexCount;i++){
                int index1=i;
                int index2=(i+1)%vertexCount;
                int index3=vertexCount;
                colorTriangles.push_back(ColorTriangle(index1,index2,index3,red,green,blue));
            }
            rotate(rotation.x,rotation.y,rotation.z);
        }
    };



}


#endif